﻿Public Class MathHelper
    ' Fields
    Public Const DegToRad As Double = Math.PI / 180
    Public Const GradToDeg As Double = 0.9
    Public Const HalfPI As Double = Math.PI * 0.5
    Public Const PI As Double = Math.PI
    Public Const RadToDeg As Double = 180.0 / Math.PI
    Public Const ThreeHalfPI As Double = Math.PI * 1.5
    Public Const TwoPI As Double = Math.PI * 2
    Public Const epsilon As Double = 0.000000000001

    ' Methods
    Public Function IsOne(ByVal number As Double) As Boolean
        Return IsOne(number, epsilon)
    End Function

    Public Function IsOne(ByVal number As Double, ByVal threshold As Double) As Boolean
        Return IsZero(number - 1, threshold)
    End Function

    Public Function IsZero(ByVal number As Double, ByVal threshold As Double) As Boolean
        Return ((number >= -threshold) AndAlso (number <= threshold))
    End Function

    Public Function IsZero(ByVal number As Double) As Boolean
        Return IsZero(number, epsilon)
    End Function

    Public Function IsEqual(ByVal a As Double, ByVal b As Double) As Boolean
        Return IsEqual(a, b, MathHelper.epsilon)
    End Function

    Public Function IsEqual(ByVal a As Double, ByVal b As Double, ByVal threshold As Double) As Boolean
        Return IsZero((a - b), threshold)
    End Function












End Class
